<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <link rel="stylesheet" href="/sys/resources/css/reset.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/style.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/invalid.css" type="text/css" media="screen"/>
    <script type="text/javascript" src="/sys/resources/scripts/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/simpla.jquery.configuration.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/facebox.js"></script>
    <title>添加权限节点</title>
</HEAD>
<BODY class="mian_bg">
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
    <TR height=28>
        <TD class="addr_td">&nbsp;&nbsp;<img src="/sys/resources/images/addr_icon.png">&nbsp;当前位置: 系统设置>添加权限节点</TD>
    </TR>
    <TR>
        <TD bgColor=#7ca600 height=1></TD>
    </TR>
    <TR>
        <TD bgColor=#8ebe00 height=1></TD>
    </TR>
</TABLE>
<div id="main-content">
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>添加权限节点</h3>

            <div class="clear"></div>
        </div>
        <div class="tab-content">
            <form action="/sys/nodeManage/addData.do" method="post" id="form" name="form" onsubmit="return false;">
                <fieldset>
                    <p>
                        <a href="/sys/nodeManage/index.do">【返回列表】</a>
                    </p>

                    <p>
                        <label>节点名称</label>
                        <input class="text-input small-input" type="text" name="name" id="name" value="${cruTNode.name}"/>
                    </p>

                    <p>
                        <label>code</label>
                        <input class="text-input small-input" type="text" name="code" id="code"
                               value="${cruTNode.code}"/>
                    </p>

                    <p>
                        <label>菜单</label>
                        <select id="navid" name="navid" onchange="getModels(this.value);">
                            <option value="">请选择</option>
                            <c:forEach var="item" items="${navs}">
                                <option value="${item.navid}" <c:if test="${selectedNav.navid == item.navid}">selected="selected" </c:if> >${item.name}</option>
                            </c:forEach>
                        </select>
                    </p>
                    <p>
                        <label>模块</label>
                        <select id="modelid" name="modelid">
                            <option value="">请选择</option>
                            <c:forEach var="item" items="${models}">
                                <option value="${item.modelid}" <c:if test="${selectedModel.modelid == item.modelid}">selected="selected" </c:if> >${item.name}</option>
                            </c:forEach>
                        </select>
                    </p>

                    <p>
                        <label>是否显示</label>
                        <input type="radio" name="status" value="1" checked="checked"/><span>是</span></label>
                        <input type="radio" name="status" value="0"/><span>否</span></label>
                    </p>

                    <p>
                        <label>节点排序</label>
                        <input class="text-input small-input" onkeyup="this.value=this.value.replace(/\D/g,'')"
                               onafterpaste="this.value=this.value.replace(/\D/g,'')" type="text" name="sort" size="4"
                               value="${cruTNode.sort}"/> 默认10
                    </p>

                    <p>
                        <input class="button" type="submit" value=" 提交 " onclick="check();"/>&nbsp;&nbsp;
                        <input class="button" type="reset" value=" 重填 "/>
                        <input type="hidden" name="nodeid" value="${cruTNode.nodeid}">
                    </p>
                </fieldset>
                <div class="clear"></div>
                <!-- End .clear -->
            </form>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">
    function check() {
        if ($("#name").val() == "") {
            alert("请完善节点名称");
            return false;
        }
        if ($("#code").val() == "") {
            alert("请完善节点url");
            return false;
        }
        if ($("#modelid").val() == "") {
            alert("请完善模块");
            return false;
        }
        form.submit();

    }


    function getModels(navid) {
        if (navid == "") {
            return;
        }
        jQuery.ajax({
            type : 'GET',
            contentType : 'application/json',
            url : '/sys/modelManage/getModels.do',
            data:{navid:navid},
            cache:false,
            dataType : 'json',
            success : function(data) {
                if (data.models != null) {
                    $("#modelid").empty();
                    for (var i = 0; i < data.models.length; i++) {
                        $("<option value='" + data.models[i].modelid + "'>" + data.models[i].name + "</option>").appendTo("#modelid")
                    }
                } else {
                    alert("获取模块数据异常!");
                }
            },
            error : function() {
                alert("error");
            }
        });
    }
</script>


</BODY>
</HTML>